﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Baosight.ZNH.ZMCommon;
using Baosight.Platform.Core.UI.Controls;
using Baosight.Platform.Core;
using Baosight.Platform.Core.ServiceModel;
using Telerik.Windows.Controls;
using Baosight.ZNH.ZMCommon.ChildWindows;
using Baosight.ZNH.ZMCB.UI.PopWindows;

namespace Baosight.ZNH.ZMCB.UI
{
    /// <summary>
    /// 查看年计划
    /// </summary>
    /// Title:ZMCB32
    /// Copyright:Baosight Software LTD.co Copyright (c) 2011
    /// Company:上海宝信软件股份有限公司
    /// Author: 王开兵
    /// Version: 1.0
    /// History:
    ///       2013-8-08  王开兵   [创建]
    ///  
    ///
    public partial class ZMCB32 : EFViewCmes
    {
        private Dictionary<object, string> TabToPageName; //存放页签与页面号的对应关系
        String year;
        String status;
        //String ForeignId;
        //String Editor;
        //EIInfo eiInfo2;

        public ZMCB32()
        {
            InitializeComponent();
            TabToPageName = new Dictionary<object, string>();
            base.BeforeAction += OnBeforeAction;
            //this.LayoutUpdated += new EventHandler(ZMCB40_LayoutUpdated);
        }

        /// <summary>
        /// 列表中修改、删除前设置属性、参数
        /// 传递到后台代码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnBeforeAction(object sender, EventArgs e)
        {
            EFViewCmesProperty _view = new EFViewCmesProperty();
            base.ViewProperty = _view;
        }

        public override void Initialize(EIInfo initData)
        {
            year = (string)initData.Get("year");
            status = (string)initData.Get("status");
            //ForeignId = (string)initData.Get("ForeignId");
            //Editor = (string)initData.Get("Editor");
            //this.titleText.Text = year + "年生产计划";
            //this.StatusText.Text = "计划状态：" + status;
            base.Initialize(initData);
            //eiInfo2 = initData;
        }

        ///// <summary>
        ///// 查询
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //public override void OnQueryButtonClick(object sender, RoutedEventArgs e)
        //{

        //    Submit(OperationMode.Query, "ZMCB32", "query", DataRange.All, queryCompleted);

        //}
        private void queryCompleted(object sender, DoWorkCompletedEventArgs e)
        {
            RefreshData();      
        }

        /// <summary>
        /// 页签改变加载不同的页面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Tab_SelectionChanged(object sender, RoutedEventArgs e)
        {
            RefreshData();
        }


        /// <summary>
        /// 刷新页签页面
        /// </summary>
        private void RefreshData()
        {
            if (TabSource.SelectedItem != null)
            {
                EFTabItem item = TabSource.SelectedItem as EFTabItem;
                item.Content = null;
                if (item.Name.Equals("tab2"))
                {
                    Dictionary<string, string> args = new Dictionary<string, string>();
                    //args.Add("fdForeignId", ForeignId);
                    args.Add("fdStatus", status);
                    args.Add("fdYear", year);
                    item.LoadView("ZMCB34", args);
                }
                else if (item.Name.Equals("tab3"))
                {
                    Dictionary<string, string> args = new Dictionary<string, string>();
                    //args.Add("fdForeignId", ForeignId);
                    args.Add("fdStatus", status);
                    args.Add("fdYear", year);
                    item.LoadView("ZMCB33", args);
                }
            }
        }

    }
}
